package cn.cas.mango.controller;

import cn.cas.mango.dto.Message;
import cn.cas.mango.dto.param.DetailParam;
import cn.cas.mango.dto.param.DetailSimParam;
import cn.cas.mango.dto.param.QueryParam;
import cn.cas.mango.service.DetailService;
import cn.cas.mango.service.GetReCmdByService2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("/ReadingAssist/news/")
@ResponseBody
@CrossOrigin
public class NewsDetail {
  @Autowired
  private DetailService detailService;
  @Autowired
  private GetReCmdByService2 getReCmdByService;


  @RequestMapping(value = "getViewHistory", method = {RequestMethod.GET, RequestMethod.POST})
  public Message getViewHistory(QueryParam queryParam)  {
    return null;
  }

  @RequestMapping(value = "getNewsDetail", method = {RequestMethod.POST})
  public Message getNewsDetailPost( DetailParam detailParam) {
    return detailService.exec(detailParam);
  }


  @RequestMapping(value = "getNewsDetail", method = {RequestMethod.GET})
  public Message getNewsDetail( DetailParam detailParam) {
    return detailService.exec(detailParam);
  }

  @RequestMapping(value = "previewNews", method = {RequestMethod.POST})
  public Message previewNewsPost( DetailParam detailParam) {
    return detailService.preViewNews(detailParam);
  }


  @RequestMapping(value = "previewNews", method = {RequestMethod.GET})
  public Message previewNews( DetailParam detailParam) {
    return detailService.preViewNews(detailParam);
  }

  @RequestMapping(value = "getSimNews", method = {RequestMethod.POST})
  public Message getSimNewsPost( DetailSimParam param) {
    return detailService.getSimNews(param);
  }

  @RequestMapping(value = "getSimNews", method = {RequestMethod.GET})
  public Message getSimNews( DetailSimParam param) {
    return detailService.getSimNews(param);
  }

  @RequestMapping(value = "getRecmdByKeywords", method = {RequestMethod.GET})
  public Message getReCmdByKeywords(DetailSimParam detailSimParam) {
    detailSimParam.setRecommendType("keywords");
    return getReCmdByService.exec(detailSimParam);
  }

  @RequestMapping(value = "getRecmdByKeywords", method = {RequestMethod.POST})
  public Message getReCmdByKeywordsPost( DetailSimParam detailSimParam) {
    detailSimParam.setRecommendType("keywords");
    return getReCmdByService.exec(detailSimParam);
  }

  @RequestMapping(value = "getRecmdByEntities", method = {RequestMethod.GET})
  public Message getReCmdByEntities(DetailSimParam detailSimParam) {
    detailSimParam.setRecommendType("entities");
    return getReCmdByService.exec(detailSimParam);
  }

  @RequestMapping(value = "getRecmdByEntities", method = {RequestMethod.POST})
  public Message getReCmdByEntitiesPost( DetailSimParam detailSimParam) {
    detailSimParam.setRecommendType("entities");
    return getReCmdByService.exec(detailSimParam);
  }

  @RequestMapping(value = "getRecmdByMLT", method = {RequestMethod.GET})
  public Message getRecmdByMLT(DetailSimParam detailSimParam) {
    detailSimParam.setRecommendType("mlt");
    return getReCmdByService.exec(detailSimParam);
  }

  @RequestMapping(value = "getRecmdByMLT", method = {RequestMethod.POST})
  public Message getRecmdByMLTPost( DetailSimParam detailSimParam) {
    detailSimParam.setRecommendType("mlt");
    return getReCmdByService.exec(detailSimParam);
  }


  @RequestMapping(value = "getRecmdByQueryWords", method = {RequestMethod.GET})
  public Message getReCmdByQueryWords(DetailSimParam detailSimParam) {
    detailSimParam.setRecommendType("keywords");
    return getReCmdByService.exec(detailSimParam);
  }

  @RequestMapping(value = "getRecmdByQueryWords", method = {RequestMethod.POST})
  public Message getReCmdByQueryWordsPost(  DetailSimParam detailSimParam) {
    detailSimParam.setRecommendType("keywords");
    return getReCmdByService.exec(detailSimParam);
  }



}
